<?php
// +----------------------------------------------------------------------
// | 有小象汇 自研正版源码 赋能开发者
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 http://www.uxphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 有小象汇并不是自由软件，未经许可不能去掉有小象汇相关版权
// +----------------------------------------------------------------------
// | Author:  有小象汇
// +----------------------------------------------------------------------

namespace app\api\controller\v1\car;


use app\Request;
use app\services\car\CarBookServices;

class CarBookController
{
    protected $services = null;

    /**
     * CarBookController constructor.
     * @param CarBookServices $services
     */
    public function __construct(CarBookServices $services){
        $this->services = $services;
    }

    /**
     * @param Request $request
     * @return mixed
     */
    public function carBookSubmit(Request $request){
        $data = $request->postMore([
            ['type_id',''],
            ['car_type_id',''],
            ['car_type_name',''],
            ['contact_name',''],
            ['contact_mobile',''],
            ['book_time',''],
            ['remark','']
        ]);
        if(!$data['contact_name']) return app('json')->fail('请输入姓名');
        if(!$data['contact_mobile']) return app('json')->fail('请输入电话');
        if(!$data['book_time']) return app('json')->fail('请选择用车时间');
        if(!$data['car_type_id']) return app('json')->fail('请选择用车类型');
        return app('json')->success($this->services->carBookSubmit($data));
    }
}
